package com.sjw.workflow.engine;

import com.sjw.workflow.core.WorkflowContext;

public class WorkflowExecutionResult {
    private final String workflowId;
    private final int completedNodes;
    private final int failedNodes;
    private final int totalNodes;
    private final long executionTime;
    private final WorkflowContext context;
    private final String error;

    public WorkflowExecutionResult(String workflowId, int completedNodes, int failedNodes,
                                   int totalNodes, long executionTime, WorkflowContext context) {
        this(workflowId, completedNodes, failedNodes, totalNodes, executionTime, context, null);
    }

    public WorkflowExecutionResult(String workflowId, int completedNodes, int failedNodes,
                                   int totalNodes, long executionTime, WorkflowContext context, String error) {
        this.workflowId = workflowId;
        this.completedNodes = completedNodes;
        this.failedNodes = failedNodes;
        this.totalNodes = totalNodes;
        this.executionTime = executionTime;
        this.context = context;
        this.error = error;
    }

    public boolean isSuccess() {
        return error == null && failedNodes == 0;
    }

    public boolean isPartialSuccess() {
        return error == null && completedNodes > 0;
    }

    public boolean isFailure() {
        return error != null || completedNodes == 0;
    }

    // Getters
    public String getWorkflowId() { return workflowId; }
    public int getCompletedNodes() { return completedNodes; }
    public int getFailedNodes() { return failedNodes; }
    public int getTotalNodes() { return totalNodes; }
    public long getExecutionTime() { return executionTime; }
    public WorkflowContext getContext() { return context; }
    public String getError() { return error; }
}
